package xian.woniu.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xian.woniu.entity.Department;
import xian.woniu.mapper.DepartmentMapper;
import xian.woniu.service.IDepartmentService;

import java.util.List;
@Service
@Transactional
public class DepartmentServiceImpl implements IDepartmentService {
    private DepartmentMapper departmentMapper;

    public DepartmentServiceImpl(DepartmentMapper departmentMapper) {
        this.departmentMapper = departmentMapper;
    }

    @Override
    public void addDepartment(Department department) {
        departmentMapper.insertSelective(department);
    }

    @Override
    public void deleteDepartment(Integer depid) {
        departmentMapper.deleteByPrimaryKey(depid);
    }

    @Override
    public void updateDepartment(Department department) {
        departmentMapper.updateByPrimaryKeySelective(department);
    }

    @Override
    public List<Department> findAllDepartment() {
        return departmentMapper.selectByExample(null);
    }

    @Override
    public Department findDepartmentBydepid(Integer depid) {
        return departmentMapper.selectByPrimaryKey(depid);
    }
}
